package edu.mse.camel.client.posterboard.ui.editor;

import java.util.HashMap;
import java.util.Map;

import org.eclipse.gef.palette.MarqueeToolEntry;
import org.eclipse.gef.palette.PaletteContainer;
import org.eclipse.gef.palette.PaletteGroup;
import org.eclipse.gef.palette.PaletteRoot;
import org.eclipse.gef.palette.PaletteSeparator;
import org.eclipse.gef.palette.PanningSelectionToolEntry;
import org.eclipse.gef.palette.ToolEntry;

import com.cea.papyrus.diagram.activity.ActivityDiagramPaletteFactory;
import com.cea.papyrus.diagram.classdiagram.ClassDiagramPaletteFactory;
import com.cea.papyrus.diagram.sequence.sedi.editor.ImageLibraryForUML2;
import com.cea.papyrus.diagram.sequence.sedi.editor.SeDiPaletteFactory;
import com.cea.papyrus.diagram.statemachine.StateMachinePaletteFactory;
import com.cea.papyrus.diagram.usecase.UseCaseDiagramPaletteFactory;
import com.cea.papyrus.diagraminterchange2.di2.DiConstants;

import edu.mse.camel.client.posterboard.ui.adapters.WhiteboardAdapter;
import edu.mse.camel.client.whiteboard.gef.ui.editor.WhiteboardEditorPaletteFactory;

public class PosterBoardEditorPaletteFactory {
	
	public static final String POSTERBOARD_PALETTE = "PosterBoardPalette";

	public static Map<String, PaletteContainer> palettes =
	 				new HashMap<String, PaletteContainer>();;
	
	/**
	 * Creates the PaletteRoot and adds all palette elements.
	 * Use this factory method to create a new palette for your graphical editor.
	 * @return a new PaletteRoot
	 */
	public static PaletteRoot createPalette() {
		PaletteRoot root = new PaletteRoot();
		PaletteContainer tools = createToolsGroup(root);
		root.add(tools);
		palettes.put(POSTERBOARD_PALETTE, tools);
		palettes.put(DiConstants.CLASS_DIAGRAM, 
				ClassDiagramPaletteFactory.createPalette());
		palettes.put(DiConstants.ACTIVITY_DIAGRAM, 
				ActivityDiagramPaletteFactory.createPalette());
		palettes.put(DiConstants.STATE_MACHINE_DIAGRAM, 
				StateMachinePaletteFactory.createPalette());
		palettes.put(DiConstants.SEQUENCE_DIAGRAM, 
				SeDiPaletteFactory.createPaletteRoot(new ImageLibraryForUML2()));
		palettes.put(DiConstants.USE_CASE_DIAGRAM, 
				UseCaseDiagramPaletteFactory.createPalette());
		palettes.put(WhiteboardAdapter.WHITEBOARD_DIAGRAM, 
				WhiteboardEditorPaletteFactory.createPalette());
		return root;
	}

	/** Create the "Tools" group. */
	private static PaletteContainer createToolsGroup(PaletteRoot palette) {
		PaletteGroup toolGroup = new PaletteGroup("Tools");
		
		// Add a selection tool to the group
		ToolEntry tool = new PanningSelectionToolEntry();
		toolGroup.add(tool);
		//palette.setDefaultEntry(tool);
		
		// Add a marquee tool to the group
		toolGroup.add(new MarqueeToolEntry());

		// Add a (unnamed) separator to the group
		toolGroup.add(new PaletteSeparator());

		return toolGroup;
	}
	
}
